﻿using shuatibao.Tool;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace shuatibao.Web.Banner
{
    public class BannerAction
    {
        public static List<BannerModel> getBannerListManager(bool hasAll) {
            string sqlStr = "";
            if (hasAll == false)
            {
                sqlStr = "select * from Banner where show = 1";
            }
            else
            {
                sqlStr = "select * from Banner";
            }


            DataRowCollection dataRows = SQLTool.sqlGetListManager(sqlStr);
            int rows = dataRows.Count;

            List<BannerModel> bannerList = new List<BannerModel>();

            for (int i = 0; i < rows; i++)
            {


        string id = dataRows[i]["id"].ToString();
                string image = dataRows[i]["image"].ToString();
                string title = dataRows[i]["title"].ToString();
                string type = dataRows[i]["type"].ToString();
                string url = dataRows[i]["url"].ToString();
                string path = dataRows[i]["path"].ToString();
                string appid = dataRows[i]["appid"].ToString();
                string color = dataRows[i]["color"].ToString();
                string subTitle = dataRows[i]["subTitle"].ToString();
                string backgroundImage = dataRows[i]["backgroundImage"].ToString();

                
                int show = Convert.ToInt32(dataRows[i]["show"].ToString());


                BannerModel bannerModel = new BannerModel()
                {
                    id = id,
                    image = image,
                    type = type,
                    title = title,
                    url = url,
                    path = path,
                    appid = appid,
                    show = show,
                    backgroundImage= backgroundImage,
                    subTitle = subTitle,
                    color=color

                };
                bannerList.Add(bannerModel);
            }

            return bannerList;
        }


    }
}